/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.demo;

import java.util.Optional;

/**
 * <p>Project: app2022 - OptionalDemo
 * <p>Powered by webrx On 2022-01-26 17:29:20
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class OptionalDemo {
    public static void main(String[] args) {
        //Optional.of(null); 不能为null
        //Optional o = Optional.ofNullable(null);

        Optional<Integer> op = Optional.ofNullable(30);
        System.out.println(op.orElse(6));
        if (op.isPresent()) {
            System.out.println(op.get());
        }
    }
}
